 {extend name="public/base" /}
{block name="container"}
 <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>地区配置</h5>
                         <div style="float: right;">
                         <a href=""><button type="button" class="btn btn-w-m btn-info">添加一级地区</button></a> 
                     </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-3" style="float: right;">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入关键词" class="input-sm form-control"> <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>名称</th>
                                        <th>编号</th>
                                        <th>添加子地区</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="list" id="vo"}
                                    <tr class="prov_{$vo['code']}">
                                        <td>
                                            <a href="javascript:;" onclick="zhankai({$vo['code']})" id="zhankai" style="display: block;" isClick="false">[+]</a>
                                            <a href="javascript:;" onclick="guanbi({$vo['code']})" id="guanbi" style="display: none;">[-]</a>
                                        </td>
                                        <td>{$vo.name}</td>
                                        <td><span class="pie">{$vo.code}</span>
                                        </td>
                                        <td><a href="javascript:;" onclick="addDistrict({$vo['code']},this);"><span class="add-child"><i class="fa  fa-plus-square"></i></span></a></td>
                                        <td>
                                             <a href="{:url('index/shop/update',array('id'=>$vo['id']))}" title="查看"><i class="iconfont icon-chakan"></i></a>
                                                &emsp;
                                            <a href="javascript:;" onclick="delshop({$vo['id']})" title="删除"><i class="iconfont icon-shanchu"></i></a>
                                        </td>
                                    </tr>
                                   {/volist}
                                </tbody>
                            </table>
                            <div style="float: right;">{$page}</div>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    {/block}
    {block name="js"}
    <!-- Peity -->
    <script src="__INDEX__/js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="__INDEX__/js/content.js?v=1.0.0"></script>
    <!-- iCheck -->
    <script src="__INDEX__/js/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
    <script>
        //显示展开的方法   利用ajax动态获取 这样数据量会小点
        function zhankai(pcode) 
        {
             $.post('/index/area/getCity', {pcode: pcode}, function(data) {
            if(data.length > 0){
                $('#zhankai').css('display','none');
                $('#guanbi').css('display','block');
                addInfo = '';
                for (var i = 0; i < data.length; i++) {
                    addInfo += '<tr class="areaTr city_pid_'+ pcode +'" id="city_id_'+data[i]['code']+'" isClick="false" isShow="true">';
                        addInfo += '<td class="areaTd" >';
                            if(data[i]['issetLowerLevel'] == 1){
                                addInfo += '<a href="javascript:;" onclick="city_tab_switch('+pcode+','+data[i]['code']+')" class="tab_jia_'+data[i]['code']+'" style="display: block;">[+]</a>';
                                addInfo += '<a href="javascript:;" onclick="city_tab_switch('+pcode+','+data[i]['code']+')" class="tab_jian_'+data[i]['code']+'" style="display: none;">[-]</a>';
                            }
                        addInfo += '</td>';
                        
                        addInfo += '<td class="areaTd city_'+data[i]['code']+'" >';
                            addInfo += '<span style="color: #ccc;">|——</span>'+data[i]['name'];
                        addInfo += '</td>';
                        
                        addInfo += '<td class="areaTd province_38" >'+data[i]['code']+'</td>';
                        
                        addInfo += '<td class="areaTd">';
                            addInfo += '<a href="javascript:;" onclick="addDistrict('+data[i]['code']+',this);"><span class="add-child"><i class="fa  fa-plus-square"></i></span></a>';
                        addInfo += '</td>';
                        addInfo += '<td class="areaTd" >';
                            addInfo += '<a href="javascript:;" onclick="updateCity('+data[i]['code']+','+ pcode +',this)" zipcode="'+data[i]['zipcode']+'" title="修改"><i class="iconfont icon-chakan"></i></a>&emsp;&nbsp;';
                            addInfo += '<a href="javascript:;" onclick="delRegion('+data[i]['code']+',2)" title="删除"><i class="iconfont icon-shanchu"></i></a>';
                        addInfo += '</td>';
                    addInfo += '</tr>';
                }
            }
            $('.prov_'+pcode).after(addInfo);
            });
        }
    </script>
    <script>
        function guanbi(code)
        {
                $('#zhankai').css('display','block');
                $('#guanbi').css('display','none');            
        }
    </script>
    {/block}